package com.expdatacloud.service.impl;

import com.expdatacloud.mapper.DifferenceMSAMapper;
import com.expdatacloud.service.DifferenceMSAService;
import com.expdatacloud.vo.StoreDifferenceVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author jie
 * @date 2019/12/23 -21:06
 */
@Service
public class DifferenceMSAServiceImpl implements DifferenceMSAService {

    @Autowired
    private DifferenceMSAMapper differenceMSAMapper;


    @Override
    public PageInfo<StoreDifferenceVo> getDiffStore(String storerkey,
                                                String sku,
                                                String lottable01,
                                                String lottable02,
                                                    String differ,
                                                    int page,
                                                    int limit) {

        String[] differArrays = differ != null ? differ.split(",") : null;
        if (differArrays != null) {
            if ((differArrays.length == 1) && "".equals(differArrays[0])) {
                differArrays = null;
            }
        }

        PageHelper.startPage(page, limit);
        PageInfo<StoreDifferenceVo> pageInfo = new PageInfo<>(differenceMSAMapper.wsmAndT100Diff(storerkey,sku,lottable01,lottable02,differArrays));
        return pageInfo;
    }

    @Override
    public List<StoreDifferenceVo> getDiffStore2(String storerkey,
                                                 String sku,
                                                 String lottable01,
                                                 String lottable02,
                                                 String differ) {

        String[] differArrays = differ != null ? differ.split(",") : null;
        if (differArrays != null) {
            if ((differArrays.length == 1) && "".equals(differArrays[0])) {
                differArrays = null;
            }
        }


        return  differenceMSAMapper.wsmAndT100Diff(storerkey,sku,lottable01,lottable02,differArrays);
    }

}
